package com.example.exp_4_javaweb;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/signupresult")
public class SignupResult extends HttpServlet {

    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");

        Student student = (Student) request.getAttribute("student");
        boolean isSignup = (Boolean) request.getAttribute("issignup");

        if (isSignup) {
            response.getWriter().println(student.getName()+",你已注册！");
        } else {
            response.getWriter().println(student.getName()+",注册成功！");
        }
    }
}
